//
//  CWUserInfo.m
//  paytong
//
//  Created by 王 友宏 on 11-1-3.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "CWUserInfo.h"

@implementation CWCardInfo

@synthesize bank;
@synthesize cardLast6;

-(void)dealloc
{
	self.bank = nil;
	self.cardLast6 = nil;
	[super dealloc];
}

@end


@implementation CWUserInfo

@synthesize userName;
@synthesize IDNo;
@synthesize password;
@synthesize name;
@synthesize email;
@synthesize mobil;
@synthesize phone;
@synthesize address;
@synthesize code;
@synthesize cardNumber;
@synthesize cardList;

-(void)initWithString:(NSString *)strValue
{
	NSArray *fields = [strValue componentsSeparatedByString:@"|"];
	
	self.userName = (NSString *)[fields objectAtIndex:2];
	self.password = (NSString *)[fields objectAtIndex:3];
	self.IDNo = (NSString *)[fields objectAtIndex:4];
	self.name = (NSString *)[fields objectAtIndex:5];
	self.email = (NSString *)[fields objectAtIndex:6];
	self.mobil = (NSString *)[fields objectAtIndex:7];
	self.phone = (NSString *)[fields objectAtIndex:8];
	self.address = (NSString *)[fields objectAtIndex:9];
	self.code = (NSString *)[fields objectAtIndex:10];
	self.cardNumber = [(NSString *)[fields objectAtIndex:11] intValue];
	self.cardList = [NSMutableArray array];
	for(int loopi=0; loopi<self.cardNumber; loopi++)
	{
		CWCardInfo *ci = [[CWCardInfo alloc] init];
		NSArray *cardF = [(NSString *)[fields objectAtIndex:loopi+12] componentsSeparatedByString:@"-"];
		ci.bank = (NSString *)[cardF objectAtIndex:0];
		ci.cardLast6 = (NSString *)[cardF objectAtIndex:1];
		[self.cardList addObject:ci];
		[ci release];
	}
}

-(void)dealloc
{
	self.userName = nil;
	self.password = nil;
	self.IDNo = nil;
	self.name = nil;
	self.email = nil;
	self.mobil = nil;
	self.phone = nil;
	self.address = nil;
	self.code = nil;
	self.cardList = nil;
	[super dealloc];
}

@end
